<?php

namespace app\admin\model;

use think\Db;
use think\Model;

class Admin extends Model
{
    public function login($data)
    {
        $arr = Db::name('admin')->where('name', $data['name'])->find();

        if ($arr) {
            if ($arr['pwd'] == md5($data['pwd'])) {
                return $arr; //信息正确
            } else {
                return false;
            }
        }
        return false;
    }

    public function dologin($data,$id)
    {
        try{
            Db::name('admin')->where('id', $id)->update($data);
        } catch(Exception $e) {
            $this->error('登录更新出错');
        }
    }

}
